<?php


    require_once "config.php";
    require_once "weixin_info.php";
    $sql = $mysql->query("select * from dyspw_member where branch_store_id = {$_SESSION['Member_info'][0]['id']} ORDER BY id ASC");
    $branch_list = $sql->fetch_all(MYSQLI_ASSOC);
    // print_r($gui_list);exit;
    foreach ($branch_list as $key => $val) {
        $hits = 0;
        $zan = 0;
        $web_sql = $mysql->query("select count(*) from dyspw_weblink where u_id = {$val['id']} ");
        $web = $web_sql->fetch_all(MYSQLI_ASSOC);
        $goods_sql = $mysql->query("select count(*) from dyspw_goods where u_id = {$val['id']} ");
        $goods = $goods_sql->fetch_all(MYSQLI_ASSOC);
        $branch_list[$key]['web'] = $web[0]['count(*)'];
        $branch_list[$key]['goods'] = $goods[0]['count(*)'];
    }
 ?>

 <!DOCTYPE html>
 <html lang="en">
 <head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <title>分店管理</title>
    <script src="js/mui.min.js"></script>
    <link href="css/mui.min.css" rel="stylesheet" />
    <link href="css/index.css" rel="stylesheet" />
    <link rel="stylesheet" href="css/core.css">
    <style lang="css">
		.pageManageTwo{
			background-color: #ffffff;
			min-height: 100vh;
			box-sizing: border-box;
			padding: 20px;
		}
		.flex-box{
			display: flex;
			flex-wrap: wrap;
		}
		.flex-between{
            width: 100%;
			display: flex;
			flex-wrap: wrap;
			justify-content: space-between;
		}
		.pageManageTwo .list{
		}

		.pageManageTwo .list .title{
			font-size: 12px;
			color: #4c4c4c;
			padding-bottom: 15px;
			padding-left: 10px;
		}


		.pageManageTwo .list .title .ll{
			width: 11%;
            text-align: center;
		}
		.pageManageTwo .list .title .nn{
			width: 89%;
			text-align: center;
		}

		.pageManageTwo .list .title .nn .son{
			width: 19%;
		}

		.pageManageTwo .list .data .item{
			background-color: #E1E5EE;
			padding: 25px 0 25px 10px;
			border-radius:5px;
			margin-bottom: 10px;
		}


		.pageManageTwo .list .data .ll{
			width: 11%;
			font-size: 15px;
			color: #4c4c4c;
			line-height: 18px;
		}
		.pageManageTwo .list .data .nn{
			width: 89%;
			text-align: center;
			font-size: 18px;
			color: #885a3d;
			line-height: 18px;
		}

		.pageManageTwo .list .data .nn .son{
			width: 19%;
                line-height: 40px;
                font-size: 14px;
		}

		.pageManageTwo .list .data .nn .son.bor{
			border-left: 1px solid rgba(188,196,217,1);
			border-right: 1px solid rgba(188,196,217,1);
		}

	</style>
 </head>
 <body>
    <section class="address-list-box">
        <header id="header" class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">分店管理</h1>
		</header>
        <div class="pageManageTwo">
			<div class="list">
				<div class="title flex-between">
					<div class="ll">头像</div>
					<div class="nn flex-box">
                        <div class="son">名称</div>
						<div class="son" style="width:15%;">视频数</div>
						<div class="son" style="width:15%">商品数</div>
                        <div class="son" style="width:32%;">手机号</div>
						<div class="son">操作</div>
					</div>
				</div>
				<div class="data">
                    <ul class="mui-table-view">
                        <?php if(!empty($branch_list)){ ?>
                            <?php foreach ($branch_list as $key => $val) { ?>
                                <li class="mui-table-view-cell address-list-item" style="padding: 0px 0px;">
                                    <div class="item flex-between" style="padding:10px 0 10px 10px;">
                						<div class="ll"><a href="member.php?id=<?php echo $val['id'] ?>"> <img src="<?php echo $val['avatar'] ?>" style="width: 40px;border-radius: 40px;"></a></div>
                						<div class="nn flex-box">
                							<div class="son"><?php echo $val['username'] ?></div>
                							<div class="son bor" style="width:15%;"><?php echo $val['web'] ?></div>
                                            <div class="son " style="width:15%;"><?php echo $val['goods'] ?></div>
                                            <div class="son bor" style="width:32%;"><?php echo $val['mobile'] ?></div>
                							<div class="son"><a href="javascript:void(0);" class="mui-icon mui-icon-trash deleteAddress" data_id="<?php echo $val['id']; ?>"></a></div>


                						</div>
                					</div>
                                    <!-- <div class="address-item-left">
                                        <p class="address-item-left-primary"><img src="<?php echo $val['avatar'] ?>" style="width: 60px;border-radius: 40px;">    <?php echo $val['username'] ?></p>
                                        <p class="address-item-left-vice" style="overflow: hidden;height: 20px;"><?php echo $val['intro'] ?> <?php echo $val['mobile'] ?>  </p>
                                    </div>
                                    <div class="address-item-right">
                                        <a href="javascript:void(0);" class="mui-icon mui-icon-trash deleteAddress" data_id="<?php echo $val['id']; ?>"></a>
                                    </div> -->
                                </li>
                            <?php } ?>
                        <?php }else{ ?>

                        <?php } ?>

                    </ul>

				</div>
			</div>
		</div>

        <a class="address-list-addbtn" href="./branch_store_add.php">绑定总店</a>
    </section>
 </body>
 <script src="js/jquery-2.2.4.min.js" type="text/javascript"></script>
 <script type="text/javascript">
    $(function () {
        mui.init();
        $('.mui-table-view').on('tap', '.deleteAddress', function() {
            var btnArray = ['取消', '确认'];
            var _this = $(this);
            var id = _this.attr("data_id");
            mui.confirm('此操作将移除分店信息，确认？', '确认信息', btnArray, function(e) {
                if (e.index == 1) {
                    var uid = '<?php echo $_SESSION['Member_info'][0]['id']; ?>';
                    $.ajax({
                        url: 'mem_run_ajax.php',
                        type: "post",
                        data: {'id':id,'mold':'delete','uid':uid,'identity':'store'} ,
                        dataType: 'json',
                        success:function(res){
                            console.log(res);
                            if(res.status == 'y'){
                                mui.alert(res.info);
                                window.location.href = "branch_store.php";
                            }else{
                                layer.open({content: res.info,skin: 'msg',time: 2 });
                            }
                        }
                    })
                } else {
                }
            })
        })
    });
 </script>
 </html>
